package com.oauth.authserver.controller;

import java.security.Principal;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Controller
public class MainController {

	@GetMapping("/")
	public String root() {
		return "redirect:/index";
	}
	
	@GetMapping("/index")
	public String index(Principal principal, Model model) {
		if (principal != null) {
			log.info("principal={}", principal);
			model.addAttribute("principal", principal);
		}
		return "index";
	}
	
	@GetMapping("/403")
	public String accessDenied() {
		return "403";
	}
}
